package com.ssy.lingxi.logistics.config;

import com.ssy.lingxi.logistics.api.constans.LogisticsServiceConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 物流服务配置类
 * @author wyx
 * @version 2.0.0
 * @date 2022-03-10
 **/
@Configuration
public class LogisticsServiceConfig {
    @Bean
    public DirectExchange logisticsExchange() {
        return new DirectExchange(LogisticsServiceConstants.LOGISTICS_SERVICE_EXCHANGE, true, true);
    }

    @Bean
    public Queue logisticsQueue() {
        return new Queue(LogisticsServiceConstants.LOGISTICS_SERVICE_QUEUE, true);
    }

    @Bean
    public Binding logisticsBinding() {
        return BindingBuilder.bind(logisticsQueue()).to(logisticsExchange()).with(LogisticsServiceConstants.LOGISTICS_SERVICE_ROUTING_KEY);
    }
}
